home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1996 April
/
CHIP 1996 aprilis (CD06).zip
/
CHIP_CD06.ISO
/
sac
/
pack
/
unrar-st.lzh
/
UNRAR.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-09
|
6KB
|
201 lines
/****** ***** ******
** ** ** ** ** ** Utilidad unRAR versión 1.00e
****** ******* ****** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** ** ** ** ** ** Versión portable y GRATUITA
** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fichero de definiciones
ELIMINE EL COMENTARIO DE ALGUNA DE LAS LINEAS DEL PRINCIPIO
PARA DEFINIR SU SISTEMA OPERATIVO.
*/
/*#define DOS*/ /* para compilar en PC DOS */
/*#define OS2*/ /* para compilar en OS/2 */
/*#define UNIX*/ /* para compilar en Unix */
#define TOS /* para compilar en ordenadores Atari ST/STE/TT/Falcon */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/*
En las definiciones genéricas siguientes puede definir el macro
opcional SETFILETIME para que UNRAR pueda manejar correctamente
el formato de fecha de su sistema operativo.
El primer argumento de SETFILETIME es FILE *DestFile, y el
segundo un puntero a una estructura de fecha del DOS.
Puede desactivar SETFILETIME con un ';' al final del nombre de
macro:
#define SETFILETIME(FPtr,DosTimePtr) ;
*/
/* definiciones genéricas DOS */
#ifdef DOS
#include <fcntl.h>
#include <io.h>
#include <dir.h>
#include <alloc.h>
typedef unsigned char UBYTE; /* variable sin signo de 8 bits */
typedef unsigned short UWORD; /* variable sin signo de 16 bits */
typedef unsigned long UDWORD; /* variable sin signo de 32 bits */
typedef long SDWORD; /* variable con signo de 32 bits */
typedef UBYTE huge * HPBYTE; /* variable tipo puntero */
#define MEMALLOC(Size) farmalloc(Size)
#define MEMFREE(Ptr) farfree(Ptr)
#define MAKEDIR(Name) mkdir(Name)
#define SETFILETIME(FPtr,DosTimePtr) setftime(fileno(FPtr),DosTimePtr)
#define PATHDIV '\\'
extern int _fmode=O_BINARY;
#endif
/* definiciones genéricas OS/2 */
#ifdef OS2
#include <fcntl.h>
typedef unsigned char UBYTE;
typedef unsigned short UWORD;
typedef unsigned long UDWORD;
typedef long SDWORD;
typedef UBYTE * HPBYTE;
#define MEMALLOC(Size) malloc(Size)
#define MEMFREE(Ptr) free(Ptr)
#define MAKEDIR(Name) mkdir(Name)
#define SETFILETIME(FPtr,DosTimePtr) setftime(fileno(FPtr),DosTimePtr)
#define PATHDIV '\\'
extern int _fmode=O_BINARY;
#endif
/* definciones genéricas Unix */
#ifdef UNIX
#include <unistd.h>
typedef unsigned char UBYTE;
typedef unsigned short UWORD;
typedef unsigned long UDWORD;
typedef long SDWORD;
typedef UBYTE * HPBYTE;
#define MEMALLOC(Size) malloc(Size)
#define MEMFREE(Ptr) free(Ptr)
#define MAKEDIR(Name) mkdir(Name,0777)
#define SETFILETIME(FPtr,DosTimePtr) ;
#define PATHDIV '/'
#endif
/* definiciones génericas TOS */
#ifdef TOS
#include <tos.h> /* Para los compiladores Turbo C/Pure C y Lattice C. */
/*#include <osbind.h>*/ /* Para el resto de compiladores. */
typedef unsigned char UBYTE;
typedef unsigned short UWORD;
typedef unsigned long UDWORD;
typedef long SDWORD;
typedef UBYTE * HPBYTE;
#define MEMALLOC(Size) malloc(Size)
#define MEMFREE(Ptr) free(Ptr)
#define MAKEDIR(Name) mkdir(Name)
#define SETFILETIME(FPtr,DosTimePtr) ;
#define PATHDIV '\\'
#endif
#define UNP_VER 15 /* versión actual del método de descompresión */
/* atributos de ficheros específicos del DOS */
#define DOSFA_RDONLY 0x01
#define DOSFA_HIDDEN 0x02
#define DOSFA_SYSTEM 0x04
#define DOSFA_LABEL 0x08
#define DOSFA_DIREC 0x10
#define DOSFA_ARCH 0x20
/* Códigos de retorno */
enum { SUCCESS,WARNING,FATAL_ERROR,CRC_ERROR,LOCK_ERROR,WRITE_ERROR,
OPEN_ERROR,USER_ERROR,MEMORY_ERROR,USER_BREAK=255 };
/* Estados para la finalización */
enum { SD_MEMORY=1,SD_FILES=2 };
/* Estados para comparación de trayectorias */
enum { COMPARE_PATH,NOT_COMPARE_PATH };
/* flags de la cabecera de archivo */
#define MHD_MULT_VOL 1
#define MHD_COMMENT 2
#define MHD_LOCK 4
#define MHD_SOLID 8
/* flags de la cabecera de fichero */
#define LHD_SPLIT_BEFORE 1
#define LHD_SPLIT_AFTER 2
#define LHD_PASSWORD 4
#define LHD_COMMENT 8
#define SKIP_IF_UNKNOWN 0x4000
#define LONG_BLOCK 0x8000
/* tipos de bloques del archivo */
enum { ALL_HEAD=0,MARK_HEAD=0x72,MAIN_HEAD=0x73,FILE_HEAD=0x74,
COMM_HEAD=0x75 };
/* Código de S.O. */
enum { MS_DOS=0 };
/* Códigos de error */
enum { EEMPTY = -1,EWRITE = 1,EREAD,EOPEN,ECLOSE,ESEEK,EMEMORY,EARCH };
struct dos_ftime {
unsigned ft_tsec : 5;
unsigned ft_min : 6;
unsigned ft_hour : 5;
unsigned ft_day : 5;
unsigned ft_month : 4;
unsigned ft_year : 7;
};
/* definiciones de cabeceras */
struct MarkHeader
{
UBYTE Mark[5];
UWORD HeadSize;
};
struct ArchiveHeader
{
UWORD HeadCRC;
UBYTE HeadType;
UWORD Flags;
UWORD HeadSize;
UBYTE Reserved[6];
};
struct FileHeader
{
UWORD HeadCRC;
UBYTE HeadType;
UWORD Flags;
UWORD HeadSize;
UDWORD PackSize;
UDWORD UnpSize;
UBYTE HostOS;
UDWORD FileCRC;
struct dos_ftime FileTime;
UBYTE UnpVer;
UBYTE Method;
UWORD NameSize;
UDWORD FileAttr;
};